





# Import dat
PS_2021_FINAL <- read_sav("PS_2021_PRUBEZNE.sav")



# OLS Regression model
ANO_17 <- lm(PAR_2017_21_ANO2011_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(ANO_17)
SPD_USVIT_17 <- lm(PAR_2017_29_OkamuraSPD_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(SPD_USVIT_17)
CSSD_17 <- lm(PAR_2017_25_ceskastrananarodnesocialni_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(CSSD_17)
KSCM_17 <- lm(PAR_2017_8_KSCM_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(KSCM_17)
ODS_17 <- lm(PAR_2017_1_ODS_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(ODS_17)
STAN_17 <- lm(PAR_2017_7_STAN_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(STAN_17)
TOP09_17 <- lm(PAR_2017_20_TOP09_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(TOP09_17)
KDU_17 <- lm(PAR_2017_24_KDU_CSL_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(KDU_17)
PIR_17 <- lm(PAR_2017_15_PIRATI_p ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(PIR_17)

ANO_2021 <- lm(ANO_2021 ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(ANO_2021)
SPOLU_2021 <- lm(SPOLU_2021 ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(SPOLU_2021)
PIR_STAN_2021 <- lm(PIR_STAN_2021 ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(PIR_STAN_2021)
SPD_2021 <- lm(SPD_2021 ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(SPD_2021)
CSSD_21 <- lm(CSSD_2021 ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(CSSD_21)
KSCM_21 <- lm(KSCM_2021 ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(KSCM_21)


VOL_UCAST_ROZDIL <- lm(VOL_UCAST_ROZDIL ~ Vzd_vysok_A + Eko_podnikatel_A + Eko_nezam_A + Nepracduch_A + Nab_rimsko_A + EXEKUCE + VEL_OBCE_VTISICICH, data=PS_2021_FINAL, weights=VOL_SEZNAM_17)
summary(VOL_UCAST_ROZDIL)


# Final version if the TABLE II after review
library(texreg)
htmlreg(list(VOL_UCAST_ROZDIL, SPOLU_2021, ODS_17, TOP09_17, KDU_17, ANO_2021, ANO_17, PIR_STAN_2021, PIR_17, STAN_17, SPD_2021, SPD_USVIT_17, CSSD_21, CSSD_17, KSCM_21, KSCM_17), # názvy modelů
        file = "./STRANY_2021_2017_FINAL_TABLE.html",# output file
        custom.model.names = c("Turnout change", "SPOLU 2021", "ODS 2017" , "TOP09 2017","KDU-ČSL 2017", "ANO 2021","ANO 2017", "PIR-STAN 2021", "Pirates 2017", "STAN 2017",
                               "SPD 2021", "SPD 2017", "ČSSD 2021","ČSSD 2017",  "KSČM 2021","KSČM 2017"), # name of the models
        reorder.coef = c( 2, 3, 4, 5, 6, 7, 8, 1),
        custom.coef.names = c("(Constant)","College degree (%)" , "Self-employed (%)" , "Unemployed (%)", 
                              "Elderly (unemployed) (%)", "Catholics (%)" , "Distraints (%) (municipality)","Number of inhabitants (10k)"), # variable names
        custom.gof.names = c("R2","Adj.R2","Number of cases"), # statistics
        digits = 3, # decimal places for coefficients and SEs
        single.row = FALSE,
        stars = numeric(0)) # display BETA and SEs under each other

